<?php

namespace Summer\Location\Http\Controllers;

use Illuminate\Routing\Controller;
use Summer\Hub\Http\Controllers\Traits\ApiReturn;
use Summer\Location\Models\AreaModel;
use Input;
use Db;
use Summer\Location\Models\TownModel;

class TownController extends Controller
{
    use ApiReturn;

    public function index(){
        $area_code=Input::get('area_code');
        if(!$area_code){
            return $this->apiError('请选择区县');
        }
        $area=AreaModel::where('code',$area_code)->first();
        if(!$area){
            return $this->apiError('查找失败');
        }
        $rdata=TownModel::getNameList($area);
        return $this->apiSuccess('操作成功',$rdata);
    }
}
